Skip to content

Method: static {...}

1: /*
2: * JB4JSON-LD
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jsonld;
19:
20: /**
21: * Configuration parameters.
22: */
23: public enum ConfigParam {
24:
25: /**
26: * Whether to ignore unknown properties when deserializing JSON-LD.
27: * <p>
28: * If set to {@code false}, an exception will be thrown when unknown property is encountered.
29: */
30: IGNORE_UNKNOWN_PROPERTIES("ignoreUnknownProperties"),
31:
32: /**
33: * Package in which to look for mapped classes.
34: * <p>
35: * The scan is important for support for polymorphism in object deserialization.
36: */
37: SCAN_PACKAGE("scanPackage"),
38:
39: /**
40: * Whether to require an identifier when serializing an object.
41: * <p>
42: * If set to {@code true} and no identifier is found (either there is no identifier field or its value is {@code
43: * null}), an exception will be thrown. If configured to {@code false}, a blank node identifier is generated if no
44: * id is present.
45: */
46: REQUIRE_ID("requireId"),
47:
48: /**
49: * Allows assuming target type from the provided Java type when no types are specified in JSON-LD.
50: * <p>
51: * If set to {@code true}, JB4JSON-LD will attempt to use the provided Java type as the target type when
52: * deserializing a JSON-LD object which has no types declared.
53: * <p>
54: * Defaults to {@code false}, in which case an exception is thrown for a typeless JSON-LD object.
55: */
56: ASSUME_TARGET_TYPE("assumeTargetType"),
57:
58: /**
59: * Enables optimistic target type resolution.
60: * <p>
61: * This means that when a an ambiguous target type is encountered during deserialization of an object (i.e.,
62: * multiple concrete classes match the data type), instead of throwing an {@link
63: * cz.cvut.kbss.jsonld.exception.AmbiguousTargetTypeException}, one of the classes will be selected for
64: * instantiation.
65: * <p>
66: * Note that enabling this behavior should probably be done together with setting {@link #IGNORE_UNKNOWN_PROPERTIES}
67: * to true, so that any JSON-LD data for which the selected target class has no mapping are ignored and do not cause
68: * an exception to be thrown.
69: * <p>
70: * Defaults to {@code false}.
71: */
72: ENABLE_OPTIMISTIC_TARGET_TYPE_RESOLUTION("enableOptimisticTargetTypeResolution"),
73:
74: /**
75: * Configures optimistic type resolution to prefer concrete superclasses if possible.
76: * <p>
77: * If optimistic target type resolution is enabled, the target type resolver will select one of the matching classes
78: * for instantiation. If this parameter is set tot {@code true}, a parent class (if concrete) will be preferred for
79: * instantiation. If not, any of the classes may be selected.
80: * <p>
81: * Defaults to {@code false}.
82: *
83: * @see #ENABLE_OPTIMISTIC_TARGET_TYPE_RESOLUTION
84: */
85: PREFER_SUPERCLASS("preferSuperclass"),
86:
87: /**
88: * Whether to serialize date/time values as the number of milliseconds since epoch (if applicable).
89: * <p>
90: * Serialization as the number of millis since epoch is the default way for {@link java.util.Date}, but is not very
91: * useful for the Java 8 datetime API. If set to {@code false}, date/time values will be serialized as String in the
92: * ISO 8601 format.
93: * <p>
94: * To provide consistent behavior of various datetime representations, this property defaults to false.
95: */
96: SERIALIZE_DATETIME_AS_MILLIS("serializeDatetimeAsMillis"),
97:
98: /**
99: * Format string used to serialize and deserialize datetime values.
100: * <p>
101: * Note that if {@link #SERIALIZE_DATETIME_AS_MILLIS} is enabled, this parameter has no effect on serialization of datetime.
102: * <p>
103: * Also note that this format applies only to full datetime values. Date or time values have to be formatted per-attribute.
104: */
105: DATE_TIME_FORMAT("datetimeFormat"),
106:
107: /**
108: * Whether to serialize individuals using expanded term definition in context.
109: *
110: * This basically means that the individual's identifier is provided directly as a string and an expanded term
111: * definition (consisting of a {@literal @id} and {@literal @type}) is added into the context, specifying that the string is an identifier.
112: */
113: SERIALIZE_INDIVIDUALS_USING_EXPANDED_DEFINITION("serializeIndividualsUsingExpandedDefinition");
114:
115: private final String name;
116:
117: ConfigParam(String name) {
118: this.name = name;
119: }
120:
121: public String getName() {
122: return name;
123: }
124: }